/*
Java source file
Copyright: Umschalt.com 2012
*/
package com.david.documentation.domain.entities.doku;

import com.david.documentation.domain.entities.AbstractEntity;
import com.david.documentation.domain.entities.category.Category;
import com.david.documentation.domain.entities.episode.Episode;
import com.david.documentation.domain.entities.link.Link;
import com.david.documentation.domain.entities.tags.Tag;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@javax.persistence.Entity
@Table(name = "doku")
@Indexed
public class Doku extends AbstractEntity{
	
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "DOKU_ID", nullable = false)
	@DocumentId
	private Long id;

	@Column(name="DOKU_NAME", length = 255, nullable = false)
	@Field(index= Index.TOKENIZED,store = Store.NO)
    private String name;

	@Column(name="DOKU_DESCRIPTION", columnDefinition="TEXT", nullable = true)
    @Field(index =Index.TOKENIZED,store = Store.NO)
	private String description;

	@Column(name="DOKU_DURATION", length = 255, nullable = true)
    private String duration;

	@Column(name="DOKU_SIZE", length = 100, nullable = true)
    private String size;

	@Column(name="DOKU_LANGUAGE", length = 100, nullable = true)
    private String language;

	@Column(name="DOKU_FORMAT", length = 100, nullable = true)
    private String format;

	@Column(name="DOKU_UPLOADER", length = 100, nullable = true)
    private String uploader;

	@Column(name="DOKU_IMAGE", length = 255, nullable = false)
    private String image_url;

	@OneToOne(cascade = CascadeType.ALL)
	private Link link;

	@ManyToMany(cascade = CascadeType.MERGE)
	@JoinTable(name = "DOKU_TAGS", joinColumns = { @JoinColumn(name = "DOKU_ID") }, inverseJoinColumns = { @JoinColumn(name = "TAG_ID") })
	private List<Tag> tags;

	@ManyToMany(cascade = CascadeType.MERGE)
	@JoinTable(name="CATEGORY_DOKU", joinColumns = { @JoinColumn(name = "DOKU_ID") }, inverseJoinColumns = { @JoinColumn(name = "CATEGORY_ID") })
	private List<Category> categorys;

	@OneToMany(cascade = CascadeType.ALL)
	private List<Episode> episodes;


	@Column(name="DOKU_DATE", nullable = true)
    private Date date;

	public Doku(){
		super();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDuration() {
		return duration;
	}

	public void setDuration(String duration) {
		this.duration = duration;
	}

	public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public String getUploader() {
		return uploader;
	}

	public void setUploader(String uploader) {
		this.uploader = uploader;
	}

	public Link getLink() {
		return link;
	}

	public void setLink(Link link) {
		this.link = link;
	}

	public List<Tag> getTags() {
		return tags;
	}

	public void setTags(List<Tag> tags) {
		this.tags = tags;
	}

	public List<Category> getCategorys() {
		return categorys;
	}

	public void setCategorys(List<Category> categorys) {
		this.categorys = categorys;
	}

	public List<Episode> getEpisodes() {
		return episodes;
	}

	public void setEpisodes(List<Episode> episodes) {
		this.episodes = episodes;
	}

	public String getImage_url() {
		return image_url;
	}

	public void setImage_url(String image_url) {
		this.image_url = image_url;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
}
